Early Preview

This is currently very much a preview. Please feel free to try things out, but don't be upset if anything is not yet working. Feedback is welcome over on our GitHub Dicussions page.

struct System.​Buffers.​SequenceReader<​T>

Assembly: System.Memory

Provides methods for reading binary and text data out of a <see cref="T:System.Buffers.ReadOnlySequence`1" /> with a focus on performance and minimal or zero heap allocations.

Properties

public long
Consumed
Gets the total number of <typeparamref name="T" /> values processed by the reader.
public ReadOnlySpan<​T>
CurrentSpan
Gets a <see cref="T:System.Span`1" /> that contains the current segment in the <see cref="P:System.Buffers.SequenceReader`1.Sequence" /> .
public int
CurrentSpanIndex
Gets the index in the <see cref="P:System.Buffers.SequenceReader`1.CurrentSpan" /> .
public bool
End
Gets a value that indicates whether there is no more data in the <see cref="P:System.Buffers.SequenceReader`1.Sequence" /> .
public long
Length
Gets the count of items in the reader's <see cref="P:System.Buffers.SequenceReader`1.Sequence" /> .
Position
Gets the current position in the <see cref="P:System.Buffers.SequenceReader`1.Sequence" /> .
public long
Remaining
Gets the remaining items in the reader's <see cref="P:System.Buffers.SequenceReader`1.Sequence" /> .
public ReadOnlySequence<​T>
Sequence
Gets the underlying <see cref="T:System.Buffers.ReadOnlySequence`1" /> for the reader.
public ReadOnlySequence<​T>
UnreadSequence
Gets the unread portion of the <see cref="P:System.Buffers.SequenceReader`1.Sequence" /> .
public ReadOnlySpan<​T>
UnreadSpan
Gets the unread portion of the <see cref="P:System.Buffers.SequenceReader`1.CurrentSpan" /> .

Methods

public void
Advance​(long count)
Moves the reader ahead a specified number of items.
count The number of items to advance.
public long
AdvancePast​(T value)
Advances past consecutive instances of the given <paramref name="value" /> .
Returns The number of positions the reader has advanced.
value The value past which the reader is to advance.
public long
AdvancePastAny​(ReadOnlySpan<​T> values)
Skips consecutive instances of any of the specified <paramref name="values" /> .
Returns The number of positions the reader has advanced.
values The values to be skipped.
public long
AdvancePastAny​(T value0, T value1)
Advances past consecutive instances of either of two specified values.
Returns The number of positions the reader has advanced.
value0 The first value to skip.
value1 The second value to skip.
public long
AdvancePastAny​(T value0, T value1, T value2)
Advances past consecutive instances of any of three specified values.
Returns The number of positions the reader has advanced.
value0 The first value to skip.
value1 The second value to skip.
value2 The third value to skip.
public long
AdvancePastAny​(T value0, T value1, T value2, T value3)
Advances past consecutive instances of any of four specified values.
Returns The number of positions the reader has advanced.
value0 The first value to skip.
value1 The second value to skip.
value2 The third value to skip.
value3 The fourth value to skip.
public void
AdvanceToEnd​()
Moves the reader to the end of the sequence.
public bool
IsNext​(ReadOnlySpan<​T> next, bool advancePast = false)
Checks whether the values specified in a read-only span are next in the sequence.
Returns <see langword="true" /> if the values are next in sequence; otherwise, <see langword="false" /> .
next The span to compare the next items to.
advancePast <see langword="true" /> to move past the <paramref name="next" /> values if they are found; otherwise, <see langword="false" /> .
public bool
IsNext​(T next, bool advancePast = false)
Checks whether a specified value is next in the sequence.
Returns <see langword="true" /> if the values are next in sequence; otherwise, <see langword="false" /> .
next The value to compare the next items to.
advancePast <see langword="true" /> to move past the <paramref name="next" /> values if they are found; otherwise, <see langword="false" /> .
public void
Rewind​(long count)
Moves the reader back the specified number of items.
count The number of items.
public bool
TryAdvanceTo​(T delimiter, bool advancePastDelimiter = true)
Searches for a specified delimiter and optionally advances past it if it is found.
Returns <see langword="true" /> if the given <paramref name="delimiter" /> was found; otherwise, <see langword="false" /> .
delimiter The delimiter to search for.
advancePastDelimiter <see langword="true" /> to move past the <paramref name="delimiter" /> if it is found; otherwise, <see langword="false" /> .
public bool
TryAdvanceToAny​(ReadOnlySpan<​T> delimiters, bool advancePastDelimiter = true)
Searches for any of a number of specified delimiters and optionally advances past the first one to be found.
Returns <see langword="true" /> if any of the given <paramref name="delimiters" /> was found; otherwise, <see langword="false" /> .
delimiters The delimiters to search for.
advancePastDelimiter <see langword="true" /> to move past the first instance of any of the given <paramref name="delimiters" /> ; <see langword="false" /> to not move past the delimiter.
public bool
TryCopyTo​(Span<​T> destination)
Copies data from the current position to the given destination span if there is enough data to fill it.
Returns <see langword="true" /> if there is enough data to completely fill the <paramref name="destination" /> span; otherwise, <see langword="false" /> .
destination Destination span to copy to.
public bool
TryPeek​(T& value)
public bool
TryPeek​(long offset, T& value)
public bool
TryRead​(T& value)
public bool
TryReadTo​(ReadOnlySequence`1& sequence, ReadOnlySpan<​T> delimiter, bool advancePastDelimiter = true)
public bool
TryReadTo​(ReadOnlySequence`1& sequence, T delimiter, bool advancePastDelimiter = true)
public bool
TryReadTo​(ReadOnlySequence`1& sequence, T delimiter, T delimiterEscape, bool advancePastDelimiter = true)
public bool
TryReadTo​(ReadOnlySpan`1& span, ReadOnlySpan<​T> delimiter, bool advancePastDelimiter = true)
public bool
TryReadTo​(ReadOnlySpan`1& span, T delimiter, bool advancePastDelimiter = true)
public bool
TryReadTo​(ReadOnlySpan`1& span, T delimiter, T delimiterEscape, bool advancePastDelimiter = true)
public bool
TryReadToAny​(ReadOnlySequence`1& sequence, ReadOnlySpan<​T> delimiters, bool advancePastDelimiter = true)
public bool
TryReadToAny​(ReadOnlySpan`1& span, ReadOnlySpan<​T> delimiters, bool advancePastDelimiter = true)
public bool
TryReadExact​(int count, ReadOnlySequence`1& sequence)
public bool
Equals​(object obj)
Inherited from ValueType
public int
GetHashCode​()
Inherited from ValueType
public string
ToString​()
Inherited from ValueType
protected void
Finalize​()
Inherited from object
public Type
GetType​()
Inherited from object
protected object
MemberwiseClone​()
Inherited from object